package com.ztp.lib.client;

public class Client {
	int id;
	String hostName;
	String userName;
	String password;
	int port;
	boolean ssl;
	
	public Client(int id,String hostName, String userName, String password, int port) throws ValidationException {
		super();
		this.id = id;
		setHostName(hostName);
		setUserName(userName);
		setPassword(password);
		setPort(port);
	}
	
	public Client(String hostName, String userName, String password, int port, boolean ssl) throws ValidationException {
		this( 0,hostName, userName, password, port);
		this.ssl = ssl;
	}
	
	public Client(int id,String hostName, String userName, String password, int port, boolean ssl) throws ValidationException {
		this( id,hostName, userName, password, port);
		this.ssl = ssl;
	}
	
	public int getId() {
		return id;
	}
	public String getHostName() {
		return hostName;
	}
	public String getUserName() {
		return userName;
	}
	public String getPassword() {
		return password;
	}
	public int getPort() {
		return port;
	}
	public boolean isSsl() {
		return ssl;
	}

	public void setHostName(String hostName) throws ValidationException {
		if(hostName == null || hostName.length() > 256) 
			throw new ValidationException("hostName == null && hostName.length() > 256");
		this.hostName = hostName;
	}
	public void setUserName(String userName) throws ValidationException {
		if(userName == null || userName.length() > 256) 
			throw new ValidationException("userName == null && userName.length() > 256");
		this.userName = userName;
	}
	public void setPassword(String password) throws ValidationException {
		if(password == null || password.length() > 256) 
			throw new ValidationException("password == null && password.length() > 256");
		this.password = password;
	}
	public void setPort(int port) throws ValidationException {
		if(port < 0 || port >= 65536) 
			throw new ValidationException("port must be between 0 and 65535");
		this.port = port;
	}
	public void setSsl(boolean ssl) {
		this.ssl = ssl;
	}


	public static class ValidationException extends Exception{
		public ValidationException(String message){
			super(message);
		}
	}
}
